home *** CD-ROM | disk | FTP | other *** search
- /* *
- * Copyright (C) 1989, Silicon Graphics, Inc. *
- * *
- * These coded instructions, statements, and computer programs contain *
- * unpublished proprietary information of Silicon Graphics, Inc., and *
- * are protected by Federal copyright law. They may not be disclosed *
- * to third parties or copied or duplicated in any form, in whole or *
- * in part, without the prior written consent of Silicon Graphics, Inc. *
- * *
- **************************************************************************/
-
- #ident "$Revision: 1.2 $"
- #ifndef _GRIO_H_
- #define _GRIO_H_
-
- /*
- * This include file contains the definitions and structures necessary
- * for a user process to make guaranteed rate i/o requests.
- */
-
- /*
- * grio_resv structure is filled in by the user process and is sent to the
- * library routine grio_request() along with the file descriptor of the
- * resouce for which the I/O rate guarantee is being requested.
- *
- * The grio_request() call will return 0 if there are no errors. If there
- * is an error the routine will return -1 and the gr_error field will
- * contain the error number. In addition, if the guarantee request is
- * denied due to lack of device bandwidth, then gr_optime, and gr_opsize
- * will contain values describing the maximum remaining bandwidth.
- *
- *
- * Return errors are:
- * The first two errors indicate an error in the library.
- * EINVAL - could not communicate to daemon
- * ESRCH - invalid procid
- *
- * These errors indicate an error in the calling process.
- * EBADF - could not stat file or file already
- * has a guarantee
- * EIO - start time is incorrect
- * ENOSPC - bandwidth could not be allocated
- * ENOENT - file does not contain any extents.
- * EACCES - cannot provide desired level of
- * guarantee (i.e HARD vs SOFT)
- */
-
- #define MAX_ERRORDEV_NAME 32
-
- typedef struct grio_resv {
- time_t gr_start; /* when to start in seconds */
- u_long gr_duration; /* how long the guarntee will last, in secs */
- u_long gr_optime; /* time to complete the op in secs */
- u_long gr_opsize; /* size of each op in bytes */
- u_long gr_flags; /* flags field */
- u_long gr_error; /* returned: error code */
- char gr_errordev[MAX_ERRORDEV_NAME];/* device that caused error */
- } grio_resv_t;
-
-
- /*
- * This structure is used to return statistics info to the caller.
- * It is used with GRIO_GET_INFO resv_type.
- * subcommands are:
- * GRIO_DEV_RESVS:
- * return number of reservations on the device
- * identified by ( device_name) in grio_blk_t
- * structure.
- * GRIO_FILE_RESVS:
- * return number of reservations on the file
- * identified by ( fs_dev, ino) pair in grio_blk_t
- * structure.
- * GRIO_PROC_RESVS:
- * return number of reservations for the process
- * identified by ( procid ) in grio_blk_t structure.
- */
- typedef struct grio_stats {
- /*
- * value dependent on the subcommand and grio_blk_t parameters.
- */
- u_long gs_count; /* current number of reservations
- * active on the device/file/proc
- */
- u_long gs_maxresv; /* maximum number of reservations
- * allowed on the device.
- * for file/proc this is the number
- * of licensed streams.
- */
- u_long gs_optiosize; /* size of the optimal i/o size
- * in bytes for this device.
- * not defined for file/proc.
- */
-
- /*
- * independent of subcommand - always returned to caller.
- * these are system wide totals.
- */
- u_long gs_resvcount; /* number of reservation requests
- * that were granted.
- */
- u_long gs_unresvcount; /* number of unreserve requests
- * that were performed.
- */
- u_long gs_resvdeniedcount; /* number of reservation requests
- * that were denied
- */
- } grio_stats_t;
-
- /*
- * Defines for the gr_flags field.
- */
- #define EXTENT_ALIGNED 0x00000001
- #define HARD_GUARANTEE 0x00000002
- #define SOFT_GUARANTEE 0x00000004
- #define TIME_GUARANTEE 0x00000008
- #define GUARANTEE_MASK 0x000000FF
-
- #define VOD_LAYOUT 0x00000100
-
- #define DEVICE_NAME_SIZE 15
-
- extern int grio_request( int, grio_resv_t *);
- extern int grio_info_request( int, int, pid_t, char *, grio_stats_t *);
- extern int grio_remove_request( int, grio_resv_t *);
- extern int grio_get_rtgkey(int, uuid_t *);
- extern int grio_use_rtgkey(int, uuid_t *);
-
- /*
- * The grio_request() library routine fills in this structure and writes
- * it to the ggd deamon.
- */
- typedef struct grio_block {
- int resv_type; /* type of reservation req */
- int sub_cmd; /* subcommand - only used for
- * GET_INFO commands
- */
- int fd; /* file descriptor */
- dev_t fs_dev; /* file system dev_t */
- pid_t procid; /* process id of requestor */
- __uint64_t ino; /* inode number */
- char device_name[DEVICE_NAME_SIZE];
- union {
- grio_resv_t grio_resv; /* grio request info */
- uuid_t uuid; /* rate transfer ticket */
- /* NOTE: when this union
- * contains a valid uuid
- * the grio_resv.gr_error
- * field can still safely
- * return an error code.
- * The uuid_t struct is
- * only 16 bytes long.
- */
- grio_stats_t grio_stats;
- } data;
- } grio_blk_t;
-
- /*
- * This structure is passed from the ggd to the kernel to
- * create a rate guaranteed ticket for an inode.
- */
- typedef struct reservation_id {
- __uint64_t ino;
- dev_t fs_dev;
- pid_t pid;
- int vod_rotate_slot;
- int vod_group_size;
- } reservation_id_t;
-
- #define NULL_VOD_SLOT -1
- #define IS_VALID_VOD(slot) (slot != NULL_VOD_SLOT)
-
-
- /*
- * Structure definitions with fields defined as known sizes.
- * This is done to have a layer of abstraction between the kernel and the
- * ggd daemon. The kernel can have 32 bit inumber, file sizes, and file
- * system sizes, but the ggd will always view them as 64 bit quantities.
- */
- typedef struct grio_file_id {
- __uint64_t ino;
- dev_t fs_dev;
- } file_id_t;
-
- typedef struct grio_bmbt_irec {
- __uint64_t br_startoff;
- __uint64_t br_startblock;
- __uint64_t br_blockcount;
- } grio_bmbt_irec_t;
-
-
- #define REQ_ID_PID_OFFSET 7
- #define REQ_ID_VCOUNT_OFFSET 0
- #define REQ_ID_VCOUNT_MASK 0xffffff80
-
- #define MAKE_REQ_PID( pid, vcount) \
- ((pid << REQ_ID_PID_OFFSET) | (vcount))
-
- #define MATCH_PID( pid1, pid2) \
- (((pid1) & (REQ_ID_VCOUNT_MASK)) == ((pid2) & (REQ_ID_VCOUNT_MASK)))
-
- #define MATCH_ID(id1, id2) \
- ((id1->ino == id2->ino) && MATCH_PID(id1->pid,id2->pid))
-
- #define MATCH_FULL_ID(id1, id2) \
- ((id1->ino == id2->ino) && (id1->pid == id2->pid))
-
- #define MATCH_DEV_ID(id1,id2) \
- ((id1->ino == id2->ino) && \
- (id1->fs_dev == id2->fs_dev) && \
- MATCH_PID((ulong_t)(id1->pid),(ulong_t)(id2->pid)) )
-
- #define MATCH_DEV_FULL_ID(id1, id2) \
- ((id1->ino == id2->ino) && \
- (id1->fs_dev == id2->fs_dev) && \
- (id1->pid == id2->pid))
-
- #define GRIO_PIPE "/tmp/grio.pipe"
- #define GRIO_PIPE_STRLEN 14
- #define GRIO_PID_LEN 10
- #define GRIO_PIPE_NAMLEN GRIO_PIPE_STRLEN + GRIO_PID_LEN
- #define GRIO_LOCK_FILE "/tmp/grio.lock"
-
- /*
- * Commands for the resv_type field.
- */
- #define GRIO_RESV_FILE 1 /* request rate guarantee on a file */
- #define GRIO_RESV_OTHER 2 /* request rate guarantee on a device */
- #define GRIO_GET_INFO 3 /* request rate info on node */
- #define GRIO_GET_TREE_INFO 4 /* request rate tree info */
- #define GRIO_UNRESV_FILE 5 /* remove rate guarantee on a file */
- #define GRIO_UNRESV_FILE_ASYNC 6 /* kernel - remove rate guarantee */
- #define GRIO_PURGE_VDEV_ASYNC 7 /* kernel - purge vdisk info cache */
- #define GRIO_GET_RGT_KEY 8
- #define GRIO_USE_RGT_KEY 9
-
- /*
- * Subcommands for the GRIO_GET_INFO command.
- */
- #define GRIO_FILE_RESVS 0
- #define GRIO_DEV_RESVS 1
- #define GRIO_PROC_RESVS 2
-
- #define GRIO_ASYNC_REQ(cmd) \
- ((cmd == GRIO_UNRESV_FILE_ASYNC) || (cmd == GRIO_PURGE_VDEV_ASYNC))
-
- /*
- * syssgi SGI_GRIO commands
- */
- #define GRIO_ADD_DISK_INFO 1
- #define GRIO_UPDATE_DISK_INFO 2
- #define GRIO_ADD_FILE_TICKET 3
- #define GRIO_REMOVE_FILE_TICKET 4
- #define GRIO_GET_DISK_INFO 5
- #define GRIO_GET_FILE_EXTENTS 6
- #define GRIO_GET_FS_BLOCK_SIZE 7
- #define GRIO_GET_INVENT 8
- #define GRIO_GET_INVENT_START 9
- #define GRIO_GET_FILE_RT 10
- #define GRIO_REMOVE_ALL_TICKETS 11
- #define GRIO_WRITE_GRIO_REQ 12
- #define GRIO_READ_GRIO_REQ 13
- #define GRIO_WRITE_GRIO_RESP 14
- #define GRIO_MARK_INODE_GRIO 15
- #define GRIO_CLEAR_INODE_GRIO 16
- #define GRIO_CREATE_RGT_KEY 17
-
-
-
- #ifdef _KERNEL
- /*
- * Kernel buffer scheduling structure.
- */
- typedef struct grio_disk_info {
- int num_ios_max;
- int num_ios_rsv;
- int num_ios_pnd;
- int opt_blk_sz;
- lock_t lock;
- buf_t bp;
- buf_t *firstbp; /* use av_forw field in bp */
- buf_t *lastbp; /* use av_back field in bp */
- } grio_disk_info_t;
-
- /*
- * Types of tickets.
- *
- */
- #define ROTATE_TYPE 1
- #define NON_ROTATE_TYPE 2
-
- #define ROTATE_TICKET(ticket) (ticket->type == ROTATE_TYPE)
- #define NON_ROTATE_TICKET(ticket) (ticket->type == NON_ROTATE_TYPE)
-
- /*
- * Kernel rate guarantee ticket. This is attached to the inode
- * of the file used for grio.
- */
- typedef struct grio_ticket {
- int type;
- int rotator_slot;
- int rotator_group_size;
- int sz;
- struct reservation_id id;
- timestruc_t lastreq;
- int iothissecond;
- struct grio_ticket *nextticket;
- } grio_ticket_t;
-
- extern int grio_strat( buf_t *);
- extern void grio_iodone( buf_t *);
- extern int grio_config( int, int, int, int, int );
- #endif
-
- /*
- * defines for grio stream count
- */
- #define DEFAULT_GRIO_STREAMS 4
- #define UNLIMITED_GRIO_STREAMS 0x100000
-
- #endif /* _GRIO_H_ */
-